(function($) {

    "use strict";

    $.fn.extend({
        clear: function() {
            return this.each(function() {

                var type = this.type;
                var tag = this.tagName.toLowerCase();

                if (tag === 'form')
                    return $(':input', this).clear();
                if (type === 'text' || type === 'password' || tag === 'textarea' || type === 'email')
                    this.value = '';
                else if (type === 'checkbox' || type === 'radio')
                    this.checked = true;
                else if (tag === 'select')
                    this.selectedIndex = 0;
            });
        }
    });

})(jQuery);


